package com.nuaa.community.dao;

import com.nuaa.community.entity.LoginTicket;
import org.apache.ibatis.annotations.*;

/**
 * ClassName: LoginTicketMapper
 * Package: com.nuaa.community.dao
 * Description:
 */
@Mapper
@Deprecated // 不推荐使用
public interface LoginTicketMapper {

    /**
     * 插入登录凭证
     * @param loginTicket
     * @return
     */
    @Insert("insert into login_ticket(user_id, ticket, status, expired) " +
            "VALUES(#{userId},#{ticket},#{status},#{expired})")
    @Options(useGeneratedKeys = true, keyProperty = "id") // 自动生成id
    int insertLoginTicket(LoginTicket loginTicket);

    /**
     * 根据ticket查询登录凭证
     * @param ticket
     * @return
     */
    @Select("select * from login_ticket where ticket = #{ticket}")
    LoginTicket selectByTicket(String ticket);

    /**
     * 更新login_ticket的status字段，退出的时候要失效
     * @param ticket
     * @param status
     * @return
     */
    @Update("update login_ticket set status = #{status} where ticket=#{ticket}")
    int updateStatus(String ticket, int status);
}
